package com.leetcode.bit;

/**
 * @author Dennis Li
 * @date 2020/7/20 21:31
 */
public class CountBits_338 {

    public int[] countBits(int num) {
        int[] dp = new int[num + 1];
        dp[0] = 0;
        for (int i = 1; i <= num; i++)
            dp[i] = (i & 1) == 1 ? dp[i >> 1] + 1 : dp[i >> 1];
        return dp;
    }

}
